/**
 * 比豆交易记录初始化
 */
var OptLog = {
    id: "OptLogTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
OptLog.initColumn = function () {
	 var columns = [
        {field: 'selectItem', radio: true},
        {title: '商户订单编号', field: 'merchantOrderNumber', align: 'center', valign: 'middle', sortable: true},
        {title: '交易记录号', field: 'dealRecordNumber', align: 'center', valign: 'middle'},
        {title: '产品名称', field: 'productType', align: 'center', valign: 'middle'},
        {title: '会员绑定手机', field: 'userPhone', align: 'center', valign: 'middle', sortable: true},
        {title: '订单金额', field: 'orderAmount', align: 'center', valign: 'middle', sortable: true},
        {title: '会员冻结比豆', field: 'userAmount', align: 'center', valign: 'middle', sortable: true},
        {title: '合伙人绑定手机', field: 'proxyPhone', align: 'center', valign: 'middle', sortable: true},
        {title: '合伙人冻结比豆', field: 'partnerAmount', align: 'center', valign: 'middle', sortable: true},
        {title: '记录创建时间', field: 'dealCreateTime', align: 'center', valign: 'middle', sortable: true},
        {title: '记录完成时间', field: 'dealEndTime', align: 'center', valign: 'middle', sortable: true},
        
        ]
    return columns;
};

/**
 * 检查是否选中
 */
OptLog.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        OptLog.seItem = selected[0];
        return true;
    }
};


/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
OptLog.formParams = function() {
    var queryData = {};
    queryData['merchantOrderNumber'] = $("#merchantOrderNumber").val();
    queryData['dealRecordNumber'] = $("#dealRecordNumber").val();
    queryData['userPhone'] = $("#userPhone").val();//绑定手机待定
    queryData['productType'] = $("#productType").val();
    queryData['dealCreateTime'] = $("#dealCreateTime").val().replace("/","-");
    if($("#dealCreateTime").val() != "") {
        if($("#dealEndTime").val() == "") {
            Feng.info("请选择结束时间！");
            return false;
        }else{
            queryData['dealEndTime'] = $("#dealEndTime").val().replace("/","-");
        }
    }
    OptLog.table.refresh({query: queryData});
};

/**
 * 积分流水明细列表
 */
OptLog.search = function () {
	
	  OptLog.table.refresh({query: OptLog.formParams()});
};


$(function () {
	 $("#dealCreateTime").attr('type','date');
	    $("#dealEndTime").attr('type','date');
    var defaultColunms = OptLog.initColumn();
    var table = new BSTable(OptLog.id, "/freezinglManag/queryfreezingManage?start=0&end=100000", defaultColunms);
    table.setPaginationType("client");
    OptLog.table = table.init();
});
